﻿using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using ICSharpCode.SharpZipLib.Zip;
using System.Diagnostics;

namespace Sublight.Plugins.SubtitleProvider.BuiltIn
{
    class Compress
    {
        internal static void compress(string filenamezip, string unzFileName, byte[] buffer)
        {
            using (ZipOutputStream s = new ZipOutputStream(File.Create(filenamezip)))
            {
                try
                {
                    ZipEntry entry = new ZipEntry(Path.GetFileName(unzFileName));
                    entry.DateTime = DateTime.Now;
                    s.PutNextEntry(entry);
                    s.Write(buffer, 0, buffer.Length);
                }
                catch (Exception ex)
                {
                    Trace.Write("Error: ");
                    Trace.WriteLine(ex.Message);
                }
                s.Finish();
                s.Close();
            }
        }
    }
}
